﻿<Window x:Class="Demo.GenericDemoWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:am="clr-namespace:Thinktecture.UIAnnotations;assembly=Thinktecture.UIAnnotations"
    Title="Generic Adorner Demo" Height="350" Width="600" MinHeight="350" MinWidth="640" WindowStartupLocation="CenterScreen"
    FontFamily="Calibri"  FontSize="14" TextOptions.TextRenderingMode="ClearType" TextOptions.TextFormattingMode="Display" UseLayoutRounding="True"
    Loaded="Window_Loaded">

    <Window.Resources>
        <Style TargetType="Image">
            <Setter Property="IsEnabled" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1},Path=IsEnabled}" />
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Opacity" Value="0.4"/>
                </Trigger>
            </Style.Triggers>
        </Style>

        <ToolBar x:Key="adornerToolbar">
            <Button ToolTip="Cut" Command="Cut">
                <Image Source="/Images/Cut.png" Stretch="None" />
            </Button>
            <Button ToolTip="Copy" Command="Copy">
                <Image Source="/Images/Copy.png" Stretch="None" />
            </Button>
            <Button ToolTip="Paste" Command="Paste">
                <Image Source="/Images/Paste.png" Stretch="None" />
            </Button>
        </ToolBar>
    </Window.Resources>
    
    <Grid Name="LayoutGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="3*" />
        </Grid.ColumnDefinitions>
        
        <TextBox Grid.ColumnSpan="3" VerticalAlignment="Center" HorizontalAlignment="Center" Width="200" Name="textBox1" 
                 am:GenericAdorners.AdornerElement="{StaticResource adornerToolbar}"
                 am:GenericAdorners.VerticalAlignment="Top"
                 am:GenericAdorners.HorizontalAlignment="Right"
                 am:GenericAdorners.Placement="VerticalOuterHorizontalInner"
                 am:GenericAdorners.Margin="0,0,0,0"
                 am:GenericAdorners.Visible="{Binding ElementName=visibleCheckBox, Path=IsChecked}"
                 am:GenericAdorners.VisibleOnFocus="{Binding ElementName=visibleOnFocusCheckBox, Path=IsChecked}" />

        <StackPanel Grid.Row="1" Grid.Column="0" Margin="12,0,6,0">
            <Label Content="_Vertical Alignment:" />
            <ComboBox Name="verticalAlignmentComboBox" SelectionChanged="verticalAlignmentComboBox_SelectionChanged" />
        </StackPanel>

        <StackPanel Grid.Row="1" Grid.Column="1" Margin="6,0,12,0">
            <Label Content="_Horizontal Alignment:" />
            <ComboBox Name="horizontalAlignmentComboBox" SelectionChanged="horizontalAlignmentComboBox_SelectionChanged" />
        </StackPanel>

        <StackPanel Grid.Row="1" Grid.Column="2" Margin="0,0,12,0">
            <Label Content="_Placement Alignment:" />
            <ComboBox Name="placementComboBox" SelectionChanged="placementComboBox_SelectionChanged" />
        </StackPanel>
        
        <StackPanel Grid.Row="2" Grid.ColumnSpan="2" Margin="12,12,12,0">
            <CheckBox Name="visibleCheckBox" Content="Visible" IsChecked="True" />
            <CheckBox Name="visibleOnFocusCheckBox" Content="VisibleOnFocus" Margin="0,4,0,0" />
        </StackPanel>

        <Button x:Name="closeButton" Content="Close" Grid.Row="3" Grid.Column="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="12,30,12,12" Width="75"  Height="25" IsCancel="True" IsDefault="True" Click="closeButton_Click" />
    </Grid>

    <Window.Background>
        <RadialGradientBrush>
            <GradientStop Color="White" Offset="0" />
            <GradientStop Color="#FFCDD6EF" Offset="1" />
        </RadialGradientBrush>
    </Window.Background>
</Window>
